package com.yjd.pub.merchant.service;

import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.comm.merchant.model.MerchantFundsModel;
import com.yjd.comm.merchant.service.IMerchantFundsService;
import com.yjd.comm.util.FrameUtil;
import com.yjd.pub.merchant.dao.IMerchantFundsDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * <b>description</b>：商户资金表业务实现<br>
 * <b>time</b>：2017-10-19 15:49:31 <br>
 * <b>author</b>：  carl
 */
@Service("merchantFundsService")
public class MerchantFundsServiceImpl extends BaseServiceImpl implements IMerchantFundsService {

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public MerchantFundsModel insert(MerchantFundsModel model) throws Exception {
		return this.merchantFundsDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(MerchantFundsModel model) throws Exception {
		return this.merchantFundsDao.updateModel(model, true);
	}

	/**
	 * 根据id删除
	 * 
	 * @param org_id
	 * @return
	 * @throws Exception
	 */
	public int delete(long org_id) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("org_id", org_id);
		return this.merchantFundsDao.deleteModel(paramMap, true);
	}

	/**
	 * 更新机构资金状况
	 *
	 * @param org_id
	 * @param param
	 * @return
	 * @throws Exception
	 */
	@Override
	public int updataByMap(Long org_id, Map param) throws Exception {
		if(org_id==null||param==null){
			FrameUtil.throwBaseException1("请求的参数不能为空");
		}
		param.put("org_id",org_id);
		return  this.merchantFundsDao.updateByMap(param,true);
	}

	@Resource
	private IMerchantFundsDao merchantFundsDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.merchantFundsDao;
	}

}
